package com.jeomo.masterdata.provider.web.controller;

import com.jeomo.base.provider.controller.BaseController;
import com.jeomo.common.core.result.CommonResult;
import com.jeomo.common.core.util.BeanCopyUtil;
import com.jeomo.masterdata.provider.web.vo.RegionVo;
import com.jeomo.masterdata.starter.entity.Region;
import com.jeomo.masterdata.starter.service.IRegionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 地区
 * @author:Jackpot
 * @create 2020-11-03 19:29
 */
@RequestMapping("/masterdata/region")
@RestController
public class RegionController extends BaseController {

    @Resource
    private IRegionService regionService;

    @GetMapping("/all/{pid}")
    @ApiOperation("根据pid查询所有区域")
    public CommonResult<List<RegionVo>> all(@PathVariable Integer pid) {
        List<Region> regions = regionService.queryRegions(pid);
        return CommonResult.success(BeanCopyUtil.copyListProperties(regions, RegionVo::new));
    }


}
